package com.imaginaryphysics.www.simplepairs;


/**
 * Extend this class to construct your custom algorithm. The sub class your create must have a
 * zero parameter Constructor and must be an outer class.
 * 
 *
 * @param <T> The class of the object that the Algorithm is designed to run on.
 * @param <R> The Result object you are using to pass information about your calculation.
 */

public abstract class Calculation  <T extends Pairable , R extends Result_block>  {	
	

	
	/**
	 * One of the two paired objects. It is set dynamically at run time.
	 */
	public T one;
	
	/**
	 * One of the two paired objects. It is set dynamically at run time.
	 */
	
	public T two;
	
	/**
	 *  Your custom result class. It is set dynamically at run time.
	 */
	public R result;
	
	protected Calculation(){
	}
	
	
	
	protected void set_result(R result){
		this.result=result;
	}
	
	protected void set_objects(T one,T two){
		this.one = one;
		this.two = two;
	}
	
	/**
	 * Run your custom defined Calculation.
	 */
	
	public abstract void run();
	
	
	/**
	 * Get the result block you set with your custom Calculation
	 * @return The block containing a Result.
	 */
	
	 public R get_result(){
		if(result != null){
		return result;
		}
		return null;
	}
	 
	 
	
}
